﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Abreu.Profile.Database;
using Abreu.Profile.ObjectClasses;

namespace Abreu.Profile.Classes
{
    public class ApplicationProperty
    {
        #region Class Members
        CorpAbreuDataContext _corpAbreuDC = new CorpAbreuDataContext();
        #endregion

        /// <summary>
        /// Gets the info of a application properties using applicationId
        /// </summary>
        /// <param name="applicationId"></param>
        /// <returns>ApplicationPropertyInfo struct</returns>
        public ApplicationPropertyInfo GetApplicationPropertyInfo(int applicationId)
        {
            ApplicationPropertyInfo applicationPropertyInfo = null;

            //Get Application Properties Info with P_ApplicationPropertyInfo_Sel
            var objApplicationItem = _corpAbreuDC.P_GetApplicationPropertyInfo(applicationId);

            foreach (P_GetApplicationPropertyInfoResult resObjApplicationItem in objApplicationItem)
            {
                applicationPropertyInfo = new ApplicationPropertyInfo(resObjApplicationItem.ApplicationPropertyId, resObjApplicationItem.ApplicationId, resObjApplicationItem.PropertyId,
                                                resObjApplicationItem.LanguageId, resObjApplicationItem.Name, resObjApplicationItem.Value, resObjApplicationItem.Notes,
                                                resObjApplicationItem.BeginDate, resObjApplicationItem.EndDate, resObjApplicationItem.StatusApplicationProperty);
            }

            //Returns Application Properties Info
            return applicationPropertyInfo;
        }
    }
}
